/*     */ package com.zimbra.cs.ldap.unboundid;
/*     */ 
/*     */ import com.unboundid.ldap.sdk.LDAPException;
/*     */ import com.unboundid.ldap.sdk.ResultCode;
/*     */ import com.zimbra.cs.ldap.LdapException;
/*     */ import java.io.IOException;
/*     */ import java.net.ConnectException;
/*     */ import java.net.UnknownHostException;
/*     */ import javax.net.ssl.SSLHandshakeException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ class UBIDLdapException
/*     */ {
/*     */   static LdapException mapToLdapException(Throwable e)
/*     */   {
/*  28 */     return mapToLdapException(null, e);
/*     */   }
/*     */   
/*     */   static LdapException mapToLdapException(String message, Throwable e) {
/*  32 */     if ((e instanceof LDAPException)) {
/*  33 */       return mapToLdapException(message, (LDAPException)e);
/*     */     }
/*  35 */     return LdapException.LDAP_ERROR(message, e);
/*     */   }
/*     */   
/*     */   static LdapException mapToLdapException(LDAPException e)
/*     */   {
/*  40 */     return mapToLdapException(null, e);
/*     */   }
/*     */   
/*     */   static LdapException mapToLdapException(String message, LDAPException e) {
/*  44 */     ResultCode rc = e.getResultCode();
/*     */     
/*  46 */     if (ResultCode.ENTRY_ALREADY_EXISTS == rc) {
/*  47 */       return LdapException.ENTRY_ALREADY_EXIST(message, e);
/*     */     }
/*  49 */     if (ResultCode.NOT_ALLOWED_ON_NONLEAF == rc) {
/*  50 */       return LdapException.CONTEXT_NOT_EMPTY(message, e);
/*     */     }
/*  52 */     if (ResultCode.UNDEFINED_ATTRIBUTE_TYPE == rc) {
/*  53 */       return LdapException.INVALID_ATTR_NAME(message, e);
/*     */     }
/*  55 */     if ((ResultCode.CONSTRAINT_VIOLATION == rc) || (ResultCode.INVALID_ATTRIBUTE_SYNTAX == rc))
/*     */     {
/*  57 */       return LdapException.INVALID_ATTR_VALUE(message, e);
/*     */     }
/*  59 */     if (ResultCode.OBJECT_CLASS_VIOLATION == rc) {
/*  60 */       return LdapException.OBJECT_CLASS_VIOLATION(message, e);
/*     */     }
/*  62 */     if (ResultCode.SIZE_LIMIT_EXCEEDED == rc) {
/*  63 */       return LdapException.SIZE_LIMIT_EXCEEDED(message, e);
/*     */     }
/*  65 */     if (ResultCode.NO_SUCH_OBJECT == rc)
/*     */     {
/*  67 */       return LdapException.ENTRY_NOT_FOUND(message, e);
/*     */     }
/*  69 */     if (ResultCode.FILTER_ERROR == rc) {
/*  70 */       return LdapException.INVALID_SEARCH_FILTER(message, e);
/*     */     }
/*     */     
/*     */ 
/*  74 */     return LdapException.LDAP_ERROR(message, e);
/*     */   }
/*     */   
/*     */ 
/*     */   static LdapException mapToExternalLdapException(String message, LDAPException e)
/*     */   {
/*  80 */     Throwable cause = e.getCause();
/*  81 */     ResultCode rc = e.getResultCode();
/*     */     
/*     */ 
/*  84 */     LdapException ldapException = mapToLdapException(message, e);
/*     */     
/*  86 */     if ((cause instanceof IOException))
/*     */     {
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  96 */       IOException ioException = (IOException)cause;
/*  97 */       String causeMsg = ioException.getMessage();
/*  98 */       IOException rootException = null;
/*  99 */       if (causeMsg != null)
/*     */       {
/*     */ 
/*     */ 
/* 103 */         if (causeMsg.contains("java.net.UnknownHostException")) {
/* 104 */           rootException = new UnknownHostException(causeMsg);
/* 105 */         } else if (causeMsg.contains("java.net.ConnectException")) {
/* 106 */           rootException = new ConnectException(causeMsg);
/* 107 */         } else if (causeMsg.contains("javax.net.ssl.SSLHandshakeException")) {
/* 108 */           rootException = new SSLHandshakeException(causeMsg);
/*     */         }
/*     */       }
/* 111 */       if (rootException != null) {
/* 112 */         ldapException.setDetail(rootException);
/*     */       } else {
/* 114 */         ldapException.setDetail(cause);
/*     */       }
/*     */     } else {
/* 117 */       String causeMsg = e.getMessage();
/*     */       
/* 119 */       Throwable rootException = null;
/* 120 */       if (causeMsg.contains("unsupported extended operation"))
/*     */       {
/*     */ 
/* 123 */         rootException = new IOException(causeMsg);
/*     */       }
/*     */       else {
/* 126 */         rootException = mapToLdapException(message, e);
/*     */       }
/*     */       
/* 129 */       ldapException.setDetail(rootException);
/*     */     }
/*     */     
/* 132 */     return ldapException;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/ldap/unboundid/UBIDLdapException.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */